# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

"""A sample skeleton vehicle app."""

import asyncio
import logging
import signal
from vehicle import vehicle  # type: ignore
# from seatadjuster import SeatAdjusterApp  # type: ignore # noqa: E40
# from wipercontrol import WiperControlApp   # type: ignore # noqa: E40
# from doorcontrol import DoorControlApp  # type: ignore # noqa: E40
# from front_light_control import FrontLightControlApp  # type: ignore # noqa: E40
# from send_message_front_light import FrontLightControlApp  # type: ignore # noqa: E40
# from glove_light_app import GloveLightApp  # type: ignore # noqa: E40
# from dome_light_app import DomeApp  # type: ignore # noqa: E40
from back_light_app import BackLightApp

from sdv.util.log import (  # type: ignore
    get_opentelemetry_log_factory,
    get_opentelemetry_log_format,
)


# Configure the VehicleApp logger with the necessary log config and level.
logging.setLogRecordFactory(get_opentelemetry_log_factory())
logging.basicConfig(format=get_opentelemetry_log_format())
logging.getLogger().setLevel("DEBUG")
logger = logging.getLogger(__name__)


async def main():
    """Main function"""
    logger.info("Starting SampleApp...")
    # Constructing SampleApp and running it.
    vehicle_app = BackLightApp(vehicle)
    await vehicle_app.run()


LOOP = asyncio.get_event_loop()
LOOP.add_signal_handler(signal.SIGTERM, LOOP.stop)
LOOP.run_until_complete(main())
LOOP.close()
